#include "GameCompleteState.h"

#include "Game.h"
#include "CreditsMenuState.h"
#include "../SGD Wrappers/CSGD_TextureManager.h"

GameCompleteState* GameCompleteState::pInstance = nullptr;
/*static*/ GameCompleteState* GameCompleteState::GetInstance( void )
{
	// Allocate the static pointer if necessary
	if( pInstance == nullptr )
		pInstance = new GameCompleteState;

	// Return the singleton
	return pInstance;
}
/*static*/ void GameCompleteState::DeleteInstance( void )
{
	delete pInstance;
	pInstance = nullptr;
}


// Update
void GameCompleteState::Update(float deltaTime)
{
	if(timer <= 0.0f)
	{
		if(CSGD_DirectInput::GetInstance()->CheckKeys() > 0)
			Game::GetInstance()->ChangeState(CreditsMenuState::GetInstance());
	}
	else
		timer -= deltaTime;
}

// Render
void GameCompleteState::Render(void) const
{
	CSGD_TextureManager::GetInstance()->Draw(imageID, 0, 0);
}

// Enter
//	- Used to initialize the game state.
void GameCompleteState::Enter(void)
{
	imageID = -1;
	timer = 1.0f;

	screenWidth = Game::GetInstance()->GetScreenWidth();
	screenHeight = Game::GetInstance()->GetScreenHeight();

	if(screenWidth == 800 && screenHeight == 600)
		imageID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("Textures/Game Complete Background Small.png"));
	else
		imageID = CSGD_TextureManager::GetInstance()->LoadTexture(_T("Textures/Game Complete Background.png"));
}

// Exit
//	- Used to clean up the game state.
void GameCompleteState::Exit(void)
{
	DeleteInstance();
}


GameCompleteState::GameCompleteState(void)
{

}
GameCompleteState::~GameCompleteState(void)
{

}